<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="${ctx}/css/sapar.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/css/common.css" />
<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
<script type="text/javascript" src="${ctx}/js/sapar.js"></script>
<script type="text/javascript" src="${ctx}/js/mask.js"></script>
<script type="text/javascript" src="${ctx}/js/WdatePicker.js"></script>
<script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
<script type="text/javascript" src="${ctx}/js/kkpager.min.js"></script>
<link rel="stylesheet" type="text/css" href="${ctx}/css/kkpager_blue.css" />
</head>
<body>
			<div id="saper-container">
			<div id="saper-hd"></div>
			<div id="saper-bd">
				<div class="table">
                    <!--表格具体内容-->
                    <div class="table-box">
                        <table>
                            <thead>
                                <tr>
                                    <th>器械ID</th>
                                    <th>器械名</th>
                                    <th>器械大小</th>
                                    <th>器械形状</th>
                                    <th>器械数量</th>
                                </tr>
                            </thead>
                            <tbody >
                                <c:if test="${tbproductList != null}">
                                	<input type="hidden" name="packageId" value="${packageId }">
                                	<input type="hidden" name="packageName" value="${packname }">
									<!-- var 是给给他起名字 -->
									<c:forEach items="${tbproductList}" var="tbproductList">
										<tr class="thispic" data="${tbproductList.productPic}">
											<td>${tbproductList.productId}</td>
											<td>${tbproductList.productName}
												<input type="hidden" name="productName" value=${tbproductList.productName }>
											</td>
											<td>${tbproductList.productSize}<input type="hidden" name="productSize" value=${tbproductList.productSize }></td>
											<td>${tbproductList.productBarcode}<input type="hidden" name="productBarCode" value=${tbproductList.productBarcode }></td>
											<td>${tbproductList.num}
												<input type="hidden" name="productNum" value=${tbproductList.num }>
											</td>
										</tr>
									</c:forEach>
								</c:if>
                            </tbody>
                        </table>
                    </div>
                </div><!--表格结束-->
                <div id="kkpager"></div>

			</div>
			<div id="saper-ft"></div>
				<div class="kv-item clearfix"  >
                </div>
			</div>    
                
</body>
<script type="text/javascript">
	$(function(){
		var totalPage = ${total};
		var pageNo = getParameter('pageIndex');
		var id = $("input[name='packageId']").val();
		var name = $("input[name='packageName']").val();
		if(!pageNo){
			pageNo = 1;
		}
		//生成分页
		//有些参数是可选的，比如lang，若不传有默认值
		kkpager.generPageHtml({
			pno : pageNo,
			//总页码
			total : totalPage,
			//链接前部
			hrefFormer : '${ctx}/wutiaoma/findQixieList',
			//链接尾部
			hrefLatter : '.do',
			getLink : function(n){
				return this.hrefFormer + this.hrefLatter + "?pageIndex="+n+'&id='+id+'&name='+name;
			}
		});
		
		$(".query-btn").click(function(){
			var index = parent.layer.getFrameIndex(window.name);
			var packageId = $('input[name="packageId"]').val();
			var packageName = $('input[name="packageName"]').val();
			
			var data = [];
			var datamap = {};
			// 器械数量 和器械名称 器械 id
			$('input[name="productId"]:checked').each(function(){
				var map = {};
				map['productId']= $(this).val();
				map['productName'] = $(this).parent().parent().find('input[name=productName]').val();
				map['productNum'] = $(this).parent().parent().find('input[name=productNum]').val();
				map['productSize'] = $(this).parent().parent().find('input[name=productSize]').val();
				map['productBarCode'] = $(this).parent().parent().find('input[name=productBarCode]').val();
				
				data.push(map);
			})
			datamap['packageId'] = packageId;
			datamap['packageName'] = packageName;
			datamap['qixiedata'] = data;
			parent.ifcollbackdata(datamap);
			parent.layer.close(index);
		})
		
		
		$(".thispic").dblclick(function(){
			var img = $(this).attr("data");
			layer.open({
			  type: 1,
			  title: false,
			  closeBtn: true,
			  shadeClose: true,
			  area: '620px',
			  offset: '100px',
			  skin: 'layui-layer-nobg',
			  content: '<img src="${ctx}'+img+'"/>'
			});
		});
	})
	

</script>

</html>